import 'package:flutter/material.dart';
import 'package:meal/components/market/registered_activity.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/utils/tools.dart';

///
/// 已报名活动
///
class MarketJoinActivity extends StatefulWidget {
  const MarketJoinActivity({Key? key}) : super(key: key);

  @override
  State<MarketJoinActivity> createState() => _MarketJoinActivityState();
}

class _MarketJoinActivityState extends State<MarketJoinActivity>
    with SingleTickerProviderStateMixin {
  late TabController _controller;

  List<String> tabs = ['全部活动', '进行中'];

  PreferredSizeWidget get bottom {
    return PreferredSize(
        preferredSize: const Size.fromHeight(Sizes.default50),
        child: Container(
          decoration: const BoxDecoration(
            color: Colors.white,
          ),
          height: Sizes.default50,
          alignment: Alignment.center,
          child: ToolsUtils.getClientTabBar(tabs, _controller),
        ));
  }

  @override
  void initState() {
    _controller = TabController(length: tabs.length, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ToolsUtils.getDefaultBackgroundColor(),
      appBar: ToolsUtils.getDefaultBrnAppBar('已报名活动', bottom: bottom),
      body: TabBarView(
        controller: _controller,
        children: const [
          MarketRegisteredActivity(),
          MarketRegisteredActivity(
            isAll: false,
          )
        ],
      ),
    );
  }
}
